import pika

# 建立与 RabbitMQ 服务器的连接
connection = pika.BlockingConnection(pika.URLParameters('amqp://guest:guest@192.168.110.135:5672'))
channel = connection.channel()

# 声明一个 fanout 类型的 exchange
channel.exchange_declare(exchange='logs', exchange_type='fanout')

# 要发送的消息
message = 'Hello, this is a broadcast message!'

# 发送消息到指定的 fanout exchange
channel.basic_publish(exchange='logs', routing_key='', body=message)
print(f" [x] Sent {message}")

# 关闭连接
connection.close()